#include <stdio.h>

void itob (int n, char s[],int b)
{
    int i = 0;
    int sign;
    sign = n;
    if (sign < 0){
        n = -n;
    }
    while(n != 0){
        s[i++] = n % b + '0';
        n /= b;
    }
    if (sign < 0)
        s[i++] = '-';
    s[i--] = '\0';
    for (int j = 0; j < i; --i,++j){
        char temp = s[j];
        s[j] = s[i];
        s[i] = temp;
    }
}

void output(char s[])
{
    for (int i = 0; s[i] != '\0'; ++i){
        printf ("%c", s[i]);
        }
    printf ("\n");
}
int main(){
    int n = 171;
    char s[50];
    itob (n, s, 16);
    output (s);
    itob (n, s, 8);
    output (s);
    itob (n ,s ,4);
    output (s);
    itob (n, s, 2);
    output (s);

    return 0;
}
